home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / PowerPlant / Slider / SliderTestView.cp < prev    next >
Text File  |  1995-04-27  |  3KB  |  122 lines

  1. // 
  2. // ===========================================================================
  3. //     SliderTestView.cp                        ©1995 Scott Squires 
  4. // ===========================================================================
  5. //
  6.  
  7. // Subclass of LView to demo Slider.cp
  8. // Real application would probably have a view that stored the Slider pointers
  9. // and then used them to 'GetSliderValue()' in a DrawSelf().   
  10. // Currently the display is only updated when the sliders are moved
  11.  
  12.  
  13. #define StdHorzSliderID 2002
  14. #define GraySliderID 2003
  15. #define BulbSliderID 2004
  16. #define CloudSliderID 2005
  17. #define BearSliderID 2006
  18. #define StdVertSliderID 2007
  19.  
  20. #include "SliderTestView.h"
  21.  
  22. #include <LView.h>
  23. #include <LListener.h>
  24.  
  25. #include "Slider.h"
  26.  
  27.  
  28.  
  29. SliderView::SliderView()
  30.     : LView()
  31.     {
  32.  
  33.     }
  34.  
  35.  
  36.  
  37. SliderView::SliderView(LStream *inStream)
  38.     : LView(inStream)
  39.     {
  40.  
  41.     }
  42.  
  43. SliderView *SliderView::CreateSliderTestStream(LStream *inStream)
  44. {
  45.     return (new SliderView(inStream));
  46.  
  47. }
  48.  
  49.  
  50. SliderView::~SliderView()
  51. {
  52.  
  53.  
  54. }
  55.  
  56.  
  57.  
  58. void SliderView::ListenToMessage(MessageT inMessage, void *ioParam)
  59. {
  60.     Str255 theNum;
  61.     Rect tempRect, box;
  62.     RGBColor tempColor, BlackRGB;
  63.     BlackRGB.red = 0;
  64.     BlackRGB.green = 0;
  65.     BlackRGB.blue = 0;
  66.     FocusDraw();
  67.     TextMode(srcCopy);
  68.     TextFont(4);
  69.     switch (inMessage) {
  70.         // Message sent from Slider when value is updated
  71.         // In this demo most values are just displayed 
  72.         
  73.     case StdHorzSliderID:
  74.          NumToString(*(long *)ioParam, theNum);
  75.         SetRect(&box, 215, 10, 245, 30);
  76.         TextBox(theNum + 1, theNum[0], &box, teFlushRight);
  77.         break;
  78.  
  79.     case GraySliderID:
  80.         NumToString(*(long *)ioParam, theNum);
  81.         SetRect(&box, 215, 75, 245, 95);
  82.         TextBox(theNum + 1, theNum[0], &box, teFlushRight);
  83.          break;
  84.  
  85.     case BulbSliderID:
  86.         NumToString(*(long *)ioParam, theNum);
  87.         SetRect(&box, 215, 117, 245, 137);
  88.         TextBox(theNum + 1, theNum[0], &box, teFlushRight);
  89.          break;
  90.  
  91.     case CloudSliderID:
  92.         NumToString(*(long *)ioParam, theNum);
  93.          SetRect(&box, 215, 155, 245, 175);
  94.         TextBox(theNum + 1, theNum[0], &box, teFlushRight);
  95.          break;
  96.  
  97.     case BearSliderID:
  98.         NumToString(*(long *)ioParam, theNum);
  99.          SetRect(&box, 215, 213, 245, 233);
  100.         TextBox(theNum + 1, theNum[0], &box, teFlushRight);
  101.          break;
  102.  
  103.  
  104.     case StdVertSliderID:
  105.         // Vertical slider controls a colored square
  106.         NumToString(*(long *)ioParam, theNum);
  107.         SetRect(&box, 275, 30, 320, 50);
  108.         TextBox(theNum + 1, theNum[0], &box, teFlushRight);
  109.  
  110.         SetRect(&tempRect, 275, 50, 325, 100);
  111.         tempColor.red = 0;
  112.         tempColor.green = *(long *)ioParam;
  113.         tempColor.blue = 0;
  114.         RGBForeColor(&tempColor);
  115.         PaintRect(&tempRect);
  116.         RGBForeColor(&BlackRGB);
  117.  
  118.         break;
  119.  
  120.     }
  121. }
  122.